/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/**
 * Autogenerated by Thrift Compiler (0.13.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.pinot.common.request;

@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"})
/**
 * AUTO GENERATED: DO NOT EDIT
 * Broker Query
 *
 */
@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.13.0)", date = "2021-09-28")
public class BrokerRequest implements org.apache.thrift.TBase<BrokerRequest, BrokerRequest._Fields>, java.io.Serializable, Cloneable, Comparable<BrokerRequest> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BrokerRequest");

  private static final org.apache.thrift.protocol.TField QUERY_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("queryType", org.apache.thrift.protocol.TType.STRUCT, (short)1);
  private static final org.apache.thrift.protocol.TField QUERY_SOURCE_FIELD_DESC = new org.apache.thrift.protocol.TField("querySource", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField TIME_INTERVAL_FIELD_DESC = new org.apache.thrift.protocol.TField("timeInterval", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField DURATION_FIELD_DESC = new org.apache.thrift.protocol.TField("duration", org.apache.thrift.protocol.TType.STRING, (short)4);
  private static final org.apache.thrift.protocol.TField FILTER_QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("filterQuery", org.apache.thrift.protocol.TType.STRUCT, (short)5);
  private static final org.apache.thrift.protocol.TField AGGREGATIONS_INFO_FIELD_DESC = new org.apache.thrift.protocol.TField("aggregationsInfo", org.apache.thrift.protocol.TType.LIST, (short)6);
  private static final org.apache.thrift.protocol.TField GROUP_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("groupBy", org.apache.thrift.protocol.TType.STRUCT, (short)7);
  private static final org.apache.thrift.protocol.TField SELECTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("selections", org.apache.thrift.protocol.TType.STRUCT, (short)8);
  private static final org.apache.thrift.protocol.TField FILTER_SUB_QUERY_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("filterSubQueryMap", org.apache.thrift.protocol.TType.STRUCT, (short)9);
  private static final org.apache.thrift.protocol.TField BUCKET_HASH_KEY_FIELD_DESC = new org.apache.thrift.protocol.TField("bucketHashKey", org.apache.thrift.protocol.TType.STRING, (short)10);
  private static final org.apache.thrift.protocol.TField ENABLE_TRACE_FIELD_DESC = new org.apache.thrift.protocol.TField("enableTrace", org.apache.thrift.protocol.TType.BOOL, (short)11);
  private static final org.apache.thrift.protocol.TField RESPONSE_FORMAT_FIELD_DESC = new org.apache.thrift.protocol.TField("responseFormat", org.apache.thrift.protocol.TType.STRING, (short)12);
  private static final org.apache.thrift.protocol.TField DEBUG_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("debugOptions", org.apache.thrift.protocol.TType.MAP, (short)13);
  private static final org.apache.thrift.protocol.TField QUERY_OPTIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("queryOptions", org.apache.thrift.protocol.TType.MAP, (short)14);
  private static final org.apache.thrift.protocol.TField HAVING_FILTER_QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("havingFilterQuery", org.apache.thrift.protocol.TType.STRUCT, (short)15);
  private static final org.apache.thrift.protocol.TField HAVING_FILTER_SUB_QUERY_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("havingFilterSubQueryMap", org.apache.thrift.protocol.TType.STRUCT, (short)16);
  private static final org.apache.thrift.protocol.TField PINOT_QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("pinotQuery", org.apache.thrift.protocol.TType.STRUCT, (short)17);
  private static final org.apache.thrift.protocol.TField ORDER_BY_FIELD_DESC = new org.apache.thrift.protocol.TField("orderBy", org.apache.thrift.protocol.TType.LIST, (short)18);
  private static final org.apache.thrift.protocol.TField LIMIT_FIELD_DESC = new org.apache.thrift.protocol.TField("limit", org.apache.thrift.protocol.TType.I32, (short)19);

  private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new BrokerRequestStandardSchemeFactory();
  private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new BrokerRequestTupleSchemeFactory();

  private @org.apache.thrift.annotation.Nullable QueryType queryType; // optional
  private @org.apache.thrift.annotation.Nullable QuerySource querySource; // optional
  private @org.apache.thrift.annotation.Nullable java.lang.String timeInterval; // optional
  private @org.apache.thrift.annotation.Nullable java.lang.String duration; // optional
  private @org.apache.thrift.annotation.Nullable FilterQuery filterQuery; // optional
  private @org.apache.thrift.annotation.Nullable java.util.List<AggregationInfo> aggregationsInfo; // optional
  private @org.apache.thrift.annotation.Nullable GroupBy groupBy; // optional
  private @org.apache.thrift.annotation.Nullable Selection selections; // optional
  private @org.apache.thrift.annotation.Nullable FilterQueryMap filterSubQueryMap; // optional
  private @org.apache.thrift.annotation.Nullable java.lang.String bucketHashKey; // optional
  private boolean enableTrace; // optional
  private @org.apache.thrift.annotation.Nullable java.lang.String responseFormat; // optional
  private @org.apache.thrift.annotation.Nullable java.util.Map<java.lang.String,java.lang.String> debugOptions; // optional
  private @org.apache.thrift.annotation.Nullable java.util.Map<java.lang.String,java.lang.String> queryOptions; // optional
  private @org.apache.thrift.annotation.Nullable HavingFilterQuery havingFilterQuery; // optional
  private @org.apache.thrift.annotation.Nullable HavingFilterQueryMap havingFilterSubQueryMap; // optional
  private @org.apache.thrift.annotation.Nullable org.apache.pinot.common.request.PinotQuery pinotQuery; // optional
  private @org.apache.thrift.annotation.Nullable java.util.List<SelectionSort> orderBy; // optional
  private int limit; // optional

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    QUERY_TYPE((short)1, "queryType"),
    QUERY_SOURCE((short)2, "querySource"),
    TIME_INTERVAL((short)3, "timeInterval"),
    DURATION((short)4, "duration"),
    FILTER_QUERY((short)5, "filterQuery"),
    AGGREGATIONS_INFO((short)6, "aggregationsInfo"),
    GROUP_BY((short)7, "groupBy"),
    SELECTIONS((short)8, "selections"),
    FILTER_SUB_QUERY_MAP((short)9, "filterSubQueryMap"),
    BUCKET_HASH_KEY((short)10, "bucketHashKey"),
    ENABLE_TRACE((short)11, "enableTrace"),
    RESPONSE_FORMAT((short)12, "responseFormat"),
    DEBUG_OPTIONS((short)13, "debugOptions"),
    QUERY_OPTIONS((short)14, "queryOptions"),
    HAVING_FILTER_QUERY((short)15, "havingFilterQuery"),
    HAVING_FILTER_SUB_QUERY_MAP((short)16, "havingFilterSubQueryMap"),
    PINOT_QUERY((short)17, "pinotQuery"),
    ORDER_BY((short)18, "orderBy"),
    LIMIT((short)19, "limit");

    private static final java.util.Map<java.lang.String, _Fields> byName = new java.util.HashMap<java.lang.String, _Fields>();

    static {
      for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // QUERY_TYPE
          return QUERY_TYPE;
        case 2: // QUERY_SOURCE
          return QUERY_SOURCE;
        case 3: // TIME_INTERVAL
          return TIME_INTERVAL;
        case 4: // DURATION
          return DURATION;
        case 5: // FILTER_QUERY
          return FILTER_QUERY;
        case 6: // AGGREGATIONS_INFO
          return AGGREGATIONS_INFO;
        case 7: // GROUP_BY
          return GROUP_BY;
        case 8: // SELECTIONS
          return SELECTIONS;
        case 9: // FILTER_SUB_QUERY_MAP
          return FILTER_SUB_QUERY_MAP;
        case 10: // BUCKET_HASH_KEY
          return BUCKET_HASH_KEY;
        case 11: // ENABLE_TRACE
          return ENABLE_TRACE;
        case 12: // RESPONSE_FORMAT
          return RESPONSE_FORMAT;
        case 13: // DEBUG_OPTIONS
          return DEBUG_OPTIONS;
        case 14: // QUERY_OPTIONS
          return QUERY_OPTIONS;
        case 15: // HAVING_FILTER_QUERY
          return HAVING_FILTER_QUERY;
        case 16: // HAVING_FILTER_SUB_QUERY_MAP
          return HAVING_FILTER_SUB_QUERY_MAP;
        case 17: // PINOT_QUERY
          return PINOT_QUERY;
        case 18: // ORDER_BY
          return ORDER_BY;
        case 19: // LIMIT
          return LIMIT;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    @org.apache.thrift.annotation.Nullable
    public static _Fields findByName(java.lang.String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final java.lang.String _fieldName;

    _Fields(short thriftId, java.lang.String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public java.lang.String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __ENABLETRACE_ISSET_ID = 0;
  private static final int __LIMIT_ISSET_ID = 1;
  private byte __isset_bitfield = 0;
  private static final _Fields optionals[] = {_Fields.QUERY_TYPE,_Fields.QUERY_SOURCE,_Fields.TIME_INTERVAL,_Fields.DURATION,_Fields.FILTER_QUERY,_Fields.AGGREGATIONS_INFO,_Fields.GROUP_BY,_Fields.SELECTIONS,_Fields.FILTER_SUB_QUERY_MAP,_Fields.BUCKET_HASH_KEY,_Fields.ENABLE_TRACE,_Fields.RESPONSE_FORMAT,_Fields.DEBUG_OPTIONS,_Fields.QUERY_OPTIONS,_Fields.HAVING_FILTER_QUERY,_Fields.HAVING_FILTER_SUB_QUERY_MAP,_Fields.PINOT_QUERY,_Fields.ORDER_BY,_Fields.LIMIT};
  public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.QUERY_TYPE, new org.apache.thrift.meta_data.FieldMetaData("queryType", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QueryType.class)));
    tmpMap.put(_Fields.QUERY_SOURCE, new org.apache.thrift.meta_data.FieldMetaData("querySource", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QuerySource.class)));
    tmpMap.put(_Fields.TIME_INTERVAL, new org.apache.thrift.meta_data.FieldMetaData("timeInterval", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.DURATION, new org.apache.thrift.meta_data.FieldMetaData("duration", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.FILTER_QUERY, new org.apache.thrift.meta_data.FieldMetaData("filterQuery", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, FilterQuery.class)));
    tmpMap.put(_Fields.AGGREGATIONS_INFO, new org.apache.thrift.meta_data.FieldMetaData("aggregationsInfo", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, AggregationInfo.class))));
    tmpMap.put(_Fields.GROUP_BY, new org.apache.thrift.meta_data.FieldMetaData("groupBy", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, GroupBy.class)));
    tmpMap.put(_Fields.SELECTIONS, new org.apache.thrift.meta_data.FieldMetaData("selections", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Selection.class)));
    tmpMap.put(_Fields.FILTER_SUB_QUERY_MAP, new org.apache.thrift.meta_data.FieldMetaData("filterSubQueryMap", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, FilterQueryMap.class)));
    tmpMap.put(_Fields.BUCKET_HASH_KEY, new org.apache.thrift.meta_data.FieldMetaData("bucketHashKey", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.ENABLE_TRACE, new org.apache.thrift.meta_data.FieldMetaData("enableTrace", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.RESPONSE_FORMAT, new org.apache.thrift.meta_data.FieldMetaData("responseFormat", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.DEBUG_OPTIONS, new org.apache.thrift.meta_data.FieldMetaData("debugOptions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
    tmpMap.put(_Fields.QUERY_OPTIONS, new org.apache.thrift.meta_data.FieldMetaData("queryOptions", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
            new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
    tmpMap.put(_Fields.HAVING_FILTER_QUERY, new org.apache.thrift.meta_data.FieldMetaData("havingFilterQuery", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HavingFilterQuery.class)));
    tmpMap.put(_Fields.HAVING_FILTER_SUB_QUERY_MAP, new org.apache.thrift.meta_data.FieldMetaData("havingFilterSubQueryMap", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, HavingFilterQueryMap.class)));
    tmpMap.put(_Fields.PINOT_QUERY, new org.apache.thrift.meta_data.FieldMetaData("pinotQuery", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.pinot.common.request.PinotQuery.class)));
    tmpMap.put(_Fields.ORDER_BY, new org.apache.thrift.meta_data.FieldMetaData("orderBy", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, SelectionSort.class))));
    tmpMap.put(_Fields.LIMIT, new org.apache.thrift.meta_data.FieldMetaData("limit", org.apache.thrift.TFieldRequirementType.OPTIONAL,
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    metaDataMap = java.util.Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BrokerRequest.class, metaDataMap);
  }

  public BrokerRequest() {
    this.limit = 0;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public BrokerRequest(BrokerRequest other) {
    __isset_bitfield = other.__isset_bitfield;
    if (other.isSetQueryType()) {
      this.queryType = new QueryType(other.queryType);
    }
    if (other.isSetQuerySource()) {
      this.querySource = new QuerySource(other.querySource);
    }
    if (other.isSetTimeInterval()) {
      this.timeInterval = other.timeInterval;
    }
    if (other.isSetDuration()) {
      this.duration = other.duration;
    }
    if (other.isSetFilterQuery()) {
      this.filterQuery = new FilterQuery(other.filterQuery);
    }
    if (other.isSetAggregationsInfo()) {
      java.util.List<AggregationInfo> __this__aggregationsInfo = new java.util.ArrayList<AggregationInfo>(other.aggregationsInfo.size());
      for (AggregationInfo other_element : other.aggregationsInfo) {
        __this__aggregationsInfo.add(new AggregationInfo(other_element));
      }
      this.aggregationsInfo = __this__aggregationsInfo;
    }
    if (other.isSetGroupBy()) {
      this.groupBy = new GroupBy(other.groupBy);
    }
    if (other.isSetSelections()) {
      this.selections = new Selection(other.selections);
    }
    if (other.isSetFilterSubQueryMap()) {
      this.filterSubQueryMap = new FilterQueryMap(other.filterSubQueryMap);
    }
    if (other.isSetBucketHashKey()) {
      this.bucketHashKey = other.bucketHashKey;
    }
    this.enableTrace = other.enableTrace;
    if (other.isSetResponseFormat()) {
      this.responseFormat = other.responseFormat;
    }
    if (other.isSetDebugOptions()) {
      java.util.Map<java.lang.String,java.lang.String> __this__debugOptions = new java.util.HashMap<java.lang.String,java.lang.String>(other.debugOptions);
      this.debugOptions = __this__debugOptions;
    }
    if (other.isSetQueryOptions()) {
      java.util.Map<java.lang.String,java.lang.String> __this__queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>(other.queryOptions);
      this.queryOptions = __this__queryOptions;
    }
    if (other.isSetHavingFilterQuery()) {
      this.havingFilterQuery = new HavingFilterQuery(other.havingFilterQuery);
    }
    if (other.isSetHavingFilterSubQueryMap()) {
      this.havingFilterSubQueryMap = new HavingFilterQueryMap(other.havingFilterSubQueryMap);
    }
    if (other.isSetPinotQuery()) {
      this.pinotQuery = new org.apache.pinot.common.request.PinotQuery(other.pinotQuery);
    }
    if (other.isSetOrderBy()) {
      java.util.List<SelectionSort> __this__orderBy = new java.util.ArrayList<SelectionSort>(other.orderBy.size());
      for (SelectionSort other_element : other.orderBy) {
        __this__orderBy.add(new SelectionSort(other_element));
      }
      this.orderBy = __this__orderBy;
    }
    this.limit = other.limit;
  }

  public BrokerRequest deepCopy() {
    return new BrokerRequest(this);
  }

  @Override
  public void clear() {
    this.queryType = null;
    this.querySource = null;
    this.timeInterval = null;
    this.duration = null;
    this.filterQuery = null;
    this.aggregationsInfo = null;
    this.groupBy = null;
    this.selections = null;
    this.filterSubQueryMap = null;
    this.bucketHashKey = null;
    setEnableTraceIsSet(false);
    this.enableTrace = false;
    this.responseFormat = null;
    this.debugOptions = null;
    this.queryOptions = null;
    this.havingFilterQuery = null;
    this.havingFilterSubQueryMap = null;
    this.pinotQuery = null;
    this.orderBy = null;
    this.limit = 0;
  }

  @org.apache.thrift.annotation.Nullable
  public QueryType getQueryType() {
    return this.queryType;
  }

  public void setQueryType(@org.apache.thrift.annotation.Nullable QueryType queryType) {
    this.queryType = queryType;
  }

  public void unsetQueryType() {
    this.queryType = null;
  }

  /** Returns true if field queryType is set (has been assigned a value) and false otherwise */
  public boolean isSetQueryType() {
    return this.queryType != null;
  }

  public void setQueryTypeIsSet(boolean value) {
    if (!value) {
      this.queryType = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public QuerySource getQuerySource() {
    return this.querySource;
  }

  public void setQuerySource(@org.apache.thrift.annotation.Nullable QuerySource querySource) {
    this.querySource = querySource;
  }

  public void unsetQuerySource() {
    this.querySource = null;
  }

  /** Returns true if field querySource is set (has been assigned a value) and false otherwise */
  public boolean isSetQuerySource() {
    return this.querySource != null;
  }

  public void setQuerySourceIsSet(boolean value) {
    if (!value) {
      this.querySource = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getTimeInterval() {
    return this.timeInterval;
  }

  public void setTimeInterval(@org.apache.thrift.annotation.Nullable java.lang.String timeInterval) {
    this.timeInterval = timeInterval;
  }

  public void unsetTimeInterval() {
    this.timeInterval = null;
  }

  /** Returns true if field timeInterval is set (has been assigned a value) and false otherwise */
  public boolean isSetTimeInterval() {
    return this.timeInterval != null;
  }

  public void setTimeIntervalIsSet(boolean value) {
    if (!value) {
      this.timeInterval = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getDuration() {
    return this.duration;
  }

  public void setDuration(@org.apache.thrift.annotation.Nullable java.lang.String duration) {
    this.duration = duration;
  }

  public void unsetDuration() {
    this.duration = null;
  }

  /** Returns true if field duration is set (has been assigned a value) and false otherwise */
  public boolean isSetDuration() {
    return this.duration != null;
  }

  public void setDurationIsSet(boolean value) {
    if (!value) {
      this.duration = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public FilterQuery getFilterQuery() {
    return this.filterQuery;
  }

  public void setFilterQuery(@org.apache.thrift.annotation.Nullable FilterQuery filterQuery) {
    this.filterQuery = filterQuery;
  }

  public void unsetFilterQuery() {
    this.filterQuery = null;
  }

  /** Returns true if field filterQuery is set (has been assigned a value) and false otherwise */
  public boolean isSetFilterQuery() {
    return this.filterQuery != null;
  }

  public void setFilterQueryIsSet(boolean value) {
    if (!value) {
      this.filterQuery = null;
    }
  }

  public int getAggregationsInfoSize() {
    return (this.aggregationsInfo == null) ? 0 : this.aggregationsInfo.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<AggregationInfo> getAggregationsInfoIterator() {
    return (this.aggregationsInfo == null) ? null : this.aggregationsInfo.iterator();
  }

  public void addToAggregationsInfo(AggregationInfo elem) {
    if (this.aggregationsInfo == null) {
      this.aggregationsInfo = new java.util.ArrayList<AggregationInfo>();
    }
    this.aggregationsInfo.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<AggregationInfo> getAggregationsInfo() {
    return this.aggregationsInfo;
  }

  public void setAggregationsInfo(@org.apache.thrift.annotation.Nullable java.util.List<AggregationInfo> aggregationsInfo) {
    this.aggregationsInfo = aggregationsInfo;
  }

  public void unsetAggregationsInfo() {
    this.aggregationsInfo = null;
  }

  /** Returns true if field aggregationsInfo is set (has been assigned a value) and false otherwise */
  public boolean isSetAggregationsInfo() {
    return this.aggregationsInfo != null;
  }

  public void setAggregationsInfoIsSet(boolean value) {
    if (!value) {
      this.aggregationsInfo = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public GroupBy getGroupBy() {
    return this.groupBy;
  }

  public void setGroupBy(@org.apache.thrift.annotation.Nullable GroupBy groupBy) {
    this.groupBy = groupBy;
  }

  public void unsetGroupBy() {
    this.groupBy = null;
  }

  /** Returns true if field groupBy is set (has been assigned a value) and false otherwise */
  public boolean isSetGroupBy() {
    return this.groupBy != null;
  }

  public void setGroupByIsSet(boolean value) {
    if (!value) {
      this.groupBy = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public Selection getSelections() {
    return this.selections;
  }

  public void setSelections(@org.apache.thrift.annotation.Nullable Selection selections) {
    this.selections = selections;
  }

  public void unsetSelections() {
    this.selections = null;
  }

  /** Returns true if field selections is set (has been assigned a value) and false otherwise */
  public boolean isSetSelections() {
    return this.selections != null;
  }

  public void setSelectionsIsSet(boolean value) {
    if (!value) {
      this.selections = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public FilterQueryMap getFilterSubQueryMap() {
    return this.filterSubQueryMap;
  }

  public void setFilterSubQueryMap(@org.apache.thrift.annotation.Nullable FilterQueryMap filterSubQueryMap) {
    this.filterSubQueryMap = filterSubQueryMap;
  }

  public void unsetFilterSubQueryMap() {
    this.filterSubQueryMap = null;
  }

  /** Returns true if field filterSubQueryMap is set (has been assigned a value) and false otherwise */
  public boolean isSetFilterSubQueryMap() {
    return this.filterSubQueryMap != null;
  }

  public void setFilterSubQueryMapIsSet(boolean value) {
    if (!value) {
      this.filterSubQueryMap = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getBucketHashKey() {
    return this.bucketHashKey;
  }

  public void setBucketHashKey(@org.apache.thrift.annotation.Nullable java.lang.String bucketHashKey) {
    this.bucketHashKey = bucketHashKey;
  }

  public void unsetBucketHashKey() {
    this.bucketHashKey = null;
  }

  /** Returns true if field bucketHashKey is set (has been assigned a value) and false otherwise */
  public boolean isSetBucketHashKey() {
    return this.bucketHashKey != null;
  }

  public void setBucketHashKeyIsSet(boolean value) {
    if (!value) {
      this.bucketHashKey = null;
    }
  }

  public boolean isEnableTrace() {
    return this.enableTrace;
  }

  public void setEnableTrace(boolean enableTrace) {
    this.enableTrace = enableTrace;
    setEnableTraceIsSet(true);
  }

  public void unsetEnableTrace() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __ENABLETRACE_ISSET_ID);
  }

  /** Returns true if field enableTrace is set (has been assigned a value) and false otherwise */
  public boolean isSetEnableTrace() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __ENABLETRACE_ISSET_ID);
  }

  public void setEnableTraceIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __ENABLETRACE_ISSET_ID, value);
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.String getResponseFormat() {
    return this.responseFormat;
  }

  public void setResponseFormat(@org.apache.thrift.annotation.Nullable java.lang.String responseFormat) {
    this.responseFormat = responseFormat;
  }

  public void unsetResponseFormat() {
    this.responseFormat = null;
  }

  /** Returns true if field responseFormat is set (has been assigned a value) and false otherwise */
  public boolean isSetResponseFormat() {
    return this.responseFormat != null;
  }

  public void setResponseFormatIsSet(boolean value) {
    if (!value) {
      this.responseFormat = null;
    }
  }

  public int getDebugOptionsSize() {
    return (this.debugOptions == null) ? 0 : this.debugOptions.size();
  }

  public void putToDebugOptions(java.lang.String key, java.lang.String val) {
    if (this.debugOptions == null) {
      this.debugOptions = new java.util.HashMap<java.lang.String,java.lang.String>();
    }
    this.debugOptions.put(key, val);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Map<java.lang.String,java.lang.String> getDebugOptions() {
    return this.debugOptions;
  }

  public void setDebugOptions(@org.apache.thrift.annotation.Nullable java.util.Map<java.lang.String,java.lang.String> debugOptions) {
    this.debugOptions = debugOptions;
  }

  public void unsetDebugOptions() {
    this.debugOptions = null;
  }

  /** Returns true if field debugOptions is set (has been assigned a value) and false otherwise */
  public boolean isSetDebugOptions() {
    return this.debugOptions != null;
  }

  public void setDebugOptionsIsSet(boolean value) {
    if (!value) {
      this.debugOptions = null;
    }
  }

  public int getQueryOptionsSize() {
    return (this.queryOptions == null) ? 0 : this.queryOptions.size();
  }

  public void putToQueryOptions(java.lang.String key, java.lang.String val) {
    if (this.queryOptions == null) {
      this.queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>();
    }
    this.queryOptions.put(key, val);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Map<java.lang.String,java.lang.String> getQueryOptions() {
    return this.queryOptions;
  }

  public void setQueryOptions(@org.apache.thrift.annotation.Nullable java.util.Map<java.lang.String,java.lang.String> queryOptions) {
    this.queryOptions = queryOptions;
  }

  public void unsetQueryOptions() {
    this.queryOptions = null;
  }

  /** Returns true if field queryOptions is set (has been assigned a value) and false otherwise */
  public boolean isSetQueryOptions() {
    return this.queryOptions != null;
  }

  public void setQueryOptionsIsSet(boolean value) {
    if (!value) {
      this.queryOptions = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public HavingFilterQuery getHavingFilterQuery() {
    return this.havingFilterQuery;
  }

  public void setHavingFilterQuery(@org.apache.thrift.annotation.Nullable HavingFilterQuery havingFilterQuery) {
    this.havingFilterQuery = havingFilterQuery;
  }

  public void unsetHavingFilterQuery() {
    this.havingFilterQuery = null;
  }

  /** Returns true if field havingFilterQuery is set (has been assigned a value) and false otherwise */
  public boolean isSetHavingFilterQuery() {
    return this.havingFilterQuery != null;
  }

  public void setHavingFilterQueryIsSet(boolean value) {
    if (!value) {
      this.havingFilterQuery = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public HavingFilterQueryMap getHavingFilterSubQueryMap() {
    return this.havingFilterSubQueryMap;
  }

  public void setHavingFilterSubQueryMap(@org.apache.thrift.annotation.Nullable HavingFilterQueryMap havingFilterSubQueryMap) {
    this.havingFilterSubQueryMap = havingFilterSubQueryMap;
  }

  public void unsetHavingFilterSubQueryMap() {
    this.havingFilterSubQueryMap = null;
  }

  /** Returns true if field havingFilterSubQueryMap is set (has been assigned a value) and false otherwise */
  public boolean isSetHavingFilterSubQueryMap() {
    return this.havingFilterSubQueryMap != null;
  }

  public void setHavingFilterSubQueryMapIsSet(boolean value) {
    if (!value) {
      this.havingFilterSubQueryMap = null;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public org.apache.pinot.common.request.PinotQuery getPinotQuery() {
    return this.pinotQuery;
  }

  public void setPinotQuery(@org.apache.thrift.annotation.Nullable org.apache.pinot.common.request.PinotQuery pinotQuery) {
    this.pinotQuery = pinotQuery;
  }

  public void unsetPinotQuery() {
    this.pinotQuery = null;
  }

  /** Returns true if field pinotQuery is set (has been assigned a value) and false otherwise */
  public boolean isSetPinotQuery() {
    return this.pinotQuery != null;
  }

  public void setPinotQueryIsSet(boolean value) {
    if (!value) {
      this.pinotQuery = null;
    }
  }

  public int getOrderBySize() {
    return (this.orderBy == null) ? 0 : this.orderBy.size();
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.Iterator<SelectionSort> getOrderByIterator() {
    return (this.orderBy == null) ? null : this.orderBy.iterator();
  }

  public void addToOrderBy(SelectionSort elem) {
    if (this.orderBy == null) {
      this.orderBy = new java.util.ArrayList<SelectionSort>();
    }
    this.orderBy.add(elem);
  }

  @org.apache.thrift.annotation.Nullable
  public java.util.List<SelectionSort> getOrderBy() {
    return this.orderBy;
  }

  public void setOrderBy(@org.apache.thrift.annotation.Nullable java.util.List<SelectionSort> orderBy) {
    this.orderBy = orderBy;
  }

  public void unsetOrderBy() {
    this.orderBy = null;
  }

  /** Returns true if field orderBy is set (has been assigned a value) and false otherwise */
  public boolean isSetOrderBy() {
    return this.orderBy != null;
  }

  public void setOrderByIsSet(boolean value) {
    if (!value) {
      this.orderBy = null;
    }
  }

  public int getLimit() {
    return this.limit;
  }

  public void setLimit(int limit) {
    this.limit = limit;
    setLimitIsSet(true);
  }

  public void unsetLimit() {
    __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __LIMIT_ISSET_ID);
  }

  /** Returns true if field limit is set (has been assigned a value) and false otherwise */
  public boolean isSetLimit() {
    return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __LIMIT_ISSET_ID);
  }

  public void setLimitIsSet(boolean value) {
    __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __LIMIT_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, @org.apache.thrift.annotation.Nullable java.lang.Object value) {
    switch (field) {
    case QUERY_TYPE:
      if (value == null) {
        unsetQueryType();
      } else {
        setQueryType((QueryType)value);
      }
      break;

    case QUERY_SOURCE:
      if (value == null) {
        unsetQuerySource();
      } else {
        setQuerySource((QuerySource)value);
      }
      break;

    case TIME_INTERVAL:
      if (value == null) {
        unsetTimeInterval();
      } else {
        setTimeInterval((java.lang.String)value);
      }
      break;

    case DURATION:
      if (value == null) {
        unsetDuration();
      } else {
        setDuration((java.lang.String)value);
      }
      break;

    case FILTER_QUERY:
      if (value == null) {
        unsetFilterQuery();
      } else {
        setFilterQuery((FilterQuery)value);
      }
      break;

    case AGGREGATIONS_INFO:
      if (value == null) {
        unsetAggregationsInfo();
      } else {
        setAggregationsInfo((java.util.List<AggregationInfo>)value);
      }
      break;

    case GROUP_BY:
      if (value == null) {
        unsetGroupBy();
      } else {
        setGroupBy((GroupBy)value);
      }
      break;

    case SELECTIONS:
      if (value == null) {
        unsetSelections();
      } else {
        setSelections((Selection)value);
      }
      break;

    case FILTER_SUB_QUERY_MAP:
      if (value == null) {
        unsetFilterSubQueryMap();
      } else {
        setFilterSubQueryMap((FilterQueryMap)value);
      }
      break;

    case BUCKET_HASH_KEY:
      if (value == null) {
        unsetBucketHashKey();
      } else {
        setBucketHashKey((java.lang.String)value);
      }
      break;

    case ENABLE_TRACE:
      if (value == null) {
        unsetEnableTrace();
      } else {
        setEnableTrace((java.lang.Boolean)value);
      }
      break;

    case RESPONSE_FORMAT:
      if (value == null) {
        unsetResponseFormat();
      } else {
        setResponseFormat((java.lang.String)value);
      }
      break;

    case DEBUG_OPTIONS:
      if (value == null) {
        unsetDebugOptions();
      } else {
        setDebugOptions((java.util.Map<java.lang.String,java.lang.String>)value);
      }
      break;

    case QUERY_OPTIONS:
      if (value == null) {
        unsetQueryOptions();
      } else {
        setQueryOptions((java.util.Map<java.lang.String,java.lang.String>)value);
      }
      break;

    case HAVING_FILTER_QUERY:
      if (value == null) {
        unsetHavingFilterQuery();
      } else {
        setHavingFilterQuery((HavingFilterQuery)value);
      }
      break;

    case HAVING_FILTER_SUB_QUERY_MAP:
      if (value == null) {
        unsetHavingFilterSubQueryMap();
      } else {
        setHavingFilterSubQueryMap((HavingFilterQueryMap)value);
      }
      break;

    case PINOT_QUERY:
      if (value == null) {
        unsetPinotQuery();
      } else {
        setPinotQuery((org.apache.pinot.common.request.PinotQuery)value);
      }
      break;

    case ORDER_BY:
      if (value == null) {
        unsetOrderBy();
      } else {
        setOrderBy((java.util.List<SelectionSort>)value);
      }
      break;

    case LIMIT:
      if (value == null) {
        unsetLimit();
      } else {
        setLimit((java.lang.Integer)value);
      }
      break;
    }
  }

  @org.apache.thrift.annotation.Nullable
  public java.lang.Object getFieldValue(_Fields field) {
    switch (field) {
    case QUERY_TYPE:
      return getQueryType();

    case QUERY_SOURCE:
      return getQuerySource();

    case TIME_INTERVAL:
      return getTimeInterval();

    case DURATION:
      return getDuration();

    case FILTER_QUERY:
      return getFilterQuery();

    case AGGREGATIONS_INFO:
      return getAggregationsInfo();

    case GROUP_BY:
      return getGroupBy();

    case SELECTIONS:
      return getSelections();

    case FILTER_SUB_QUERY_MAP:
      return getFilterSubQueryMap();

    case BUCKET_HASH_KEY:
      return getBucketHashKey();

    case ENABLE_TRACE:
      return isEnableTrace();

    case RESPONSE_FORMAT:
      return getResponseFormat();

    case DEBUG_OPTIONS:
      return getDebugOptions();

    case QUERY_OPTIONS:
      return getQueryOptions();

    case HAVING_FILTER_QUERY:
      return getHavingFilterQuery();

    case HAVING_FILTER_SUB_QUERY_MAP:
      return getHavingFilterSubQueryMap();

    case PINOT_QUERY:
      return getPinotQuery();

    case ORDER_BY:
      return getOrderBy();

    case LIMIT:
      return getLimit();
    }
    throw new java.lang.IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new java.lang.IllegalArgumentException();
    }

    switch (field) {
    case QUERY_TYPE:
      return isSetQueryType();
    case QUERY_SOURCE:
      return isSetQuerySource();
    case TIME_INTERVAL:
      return isSetTimeInterval();
    case DURATION:
      return isSetDuration();
    case FILTER_QUERY:
      return isSetFilterQuery();
    case AGGREGATIONS_INFO:
      return isSetAggregationsInfo();
    case GROUP_BY:
      return isSetGroupBy();
    case SELECTIONS:
      return isSetSelections();
    case FILTER_SUB_QUERY_MAP:
      return isSetFilterSubQueryMap();
    case BUCKET_HASH_KEY:
      return isSetBucketHashKey();
    case ENABLE_TRACE:
      return isSetEnableTrace();
    case RESPONSE_FORMAT:
      return isSetResponseFormat();
    case DEBUG_OPTIONS:
      return isSetDebugOptions();
    case QUERY_OPTIONS:
      return isSetQueryOptions();
    case HAVING_FILTER_QUERY:
      return isSetHavingFilterQuery();
    case HAVING_FILTER_SUB_QUERY_MAP:
      return isSetHavingFilterSubQueryMap();
    case PINOT_QUERY:
      return isSetPinotQuery();
    case ORDER_BY:
      return isSetOrderBy();
    case LIMIT:
      return isSetLimit();
    }
    throw new java.lang.IllegalStateException();
  }

  @Override
  public boolean equals(java.lang.Object that) {
    if (that == null)
      return false;
    if (that instanceof BrokerRequest)
      return this.equals((BrokerRequest)that);
    return false;
  }

  public boolean equals(BrokerRequest that) {
    if (that == null)
      return false;
    if (this == that)
      return true;

    boolean this_present_queryType = true && this.isSetQueryType();
    boolean that_present_queryType = true && that.isSetQueryType();
    if (this_present_queryType || that_present_queryType) {
      if (!(this_present_queryType && that_present_queryType))
        return false;
      if (!this.queryType.equals(that.queryType))
        return false;
    }

    boolean this_present_querySource = true && this.isSetQuerySource();
    boolean that_present_querySource = true && that.isSetQuerySource();
    if (this_present_querySource || that_present_querySource) {
      if (!(this_present_querySource && that_present_querySource))
        return false;
      if (!this.querySource.equals(that.querySource))
        return false;
    }

    boolean this_present_timeInterval = true && this.isSetTimeInterval();
    boolean that_present_timeInterval = true && that.isSetTimeInterval();
    if (this_present_timeInterval || that_present_timeInterval) {
      if (!(this_present_timeInterval && that_present_timeInterval))
        return false;
      if (!this.timeInterval.equals(that.timeInterval))
        return false;
    }

    boolean this_present_duration = true && this.isSetDuration();
    boolean that_present_duration = true && that.isSetDuration();
    if (this_present_duration || that_present_duration) {
      if (!(this_present_duration && that_present_duration))
        return false;
      if (!this.duration.equals(that.duration))
        return false;
    }

    boolean this_present_filterQuery = true && this.isSetFilterQuery();
    boolean that_present_filterQuery = true && that.isSetFilterQuery();
    if (this_present_filterQuery || that_present_filterQuery) {
      if (!(this_present_filterQuery && that_present_filterQuery))
        return false;
      if (!this.filterQuery.equals(that.filterQuery))
        return false;
    }

    boolean this_present_aggregationsInfo = true && this.isSetAggregationsInfo();
    boolean that_present_aggregationsInfo = true && that.isSetAggregationsInfo();
    if (this_present_aggregationsInfo || that_present_aggregationsInfo) {
      if (!(this_present_aggregationsInfo && that_present_aggregationsInfo))
        return false;
      if (!this.aggregationsInfo.equals(that.aggregationsInfo))
        return false;
    }

    boolean this_present_groupBy = true && this.isSetGroupBy();
    boolean that_present_groupBy = true && that.isSetGroupBy();
    if (this_present_groupBy || that_present_groupBy) {
      if (!(this_present_groupBy && that_present_groupBy))
        return false;
      if (!this.groupBy.equals(that.groupBy))
        return false;
    }

    boolean this_present_selections = true && this.isSetSelections();
    boolean that_present_selections = true && that.isSetSelections();
    if (this_present_selections || that_present_selections) {
      if (!(this_present_selections && that_present_selections))
        return false;
      if (!this.selections.equals(that.selections))
        return false;
    }

    boolean this_present_filterSubQueryMap = true && this.isSetFilterSubQueryMap();
    boolean that_present_filterSubQueryMap = true && that.isSetFilterSubQueryMap();
    if (this_present_filterSubQueryMap || that_present_filterSubQueryMap) {
      if (!(this_present_filterSubQueryMap && that_present_filterSubQueryMap))
        return false;
      if (!this.filterSubQueryMap.equals(that.filterSubQueryMap))
        return false;
    }

    boolean this_present_bucketHashKey = true && this.isSetBucketHashKey();
    boolean that_present_bucketHashKey = true && that.isSetBucketHashKey();
    if (this_present_bucketHashKey || that_present_bucketHashKey) {
      if (!(this_present_bucketHashKey && that_present_bucketHashKey))
        return false;
      if (!this.bucketHashKey.equals(that.bucketHashKey))
        return false;
    }

    boolean this_present_enableTrace = true && this.isSetEnableTrace();
    boolean that_present_enableTrace = true && that.isSetEnableTrace();
    if (this_present_enableTrace || that_present_enableTrace) {
      if (!(this_present_enableTrace && that_present_enableTrace))
        return false;
      if (this.enableTrace != that.enableTrace)
        return false;
    }

    boolean this_present_responseFormat = true && this.isSetResponseFormat();
    boolean that_present_responseFormat = true && that.isSetResponseFormat();
    if (this_present_responseFormat || that_present_responseFormat) {
      if (!(this_present_responseFormat && that_present_responseFormat))
        return false;
      if (!this.responseFormat.equals(that.responseFormat))
        return false;
    }

    boolean this_present_debugOptions = true && this.isSetDebugOptions();
    boolean that_present_debugOptions = true && that.isSetDebugOptions();
    if (this_present_debugOptions || that_present_debugOptions) {
      if (!(this_present_debugOptions && that_present_debugOptions))
        return false;
      if (!this.debugOptions.equals(that.debugOptions))
        return false;
    }

    boolean this_present_queryOptions = true && this.isSetQueryOptions();
    boolean that_present_queryOptions = true && that.isSetQueryOptions();
    if (this_present_queryOptions || that_present_queryOptions) {
      if (!(this_present_queryOptions && that_present_queryOptions))
        return false;
      if (!this.queryOptions.equals(that.queryOptions))
        return false;
    }

    boolean this_present_havingFilterQuery = true && this.isSetHavingFilterQuery();
    boolean that_present_havingFilterQuery = true && that.isSetHavingFilterQuery();
    if (this_present_havingFilterQuery || that_present_havingFilterQuery) {
      if (!(this_present_havingFilterQuery && that_present_havingFilterQuery))
        return false;
      if (!this.havingFilterQuery.equals(that.havingFilterQuery))
        return false;
    }

    boolean this_present_havingFilterSubQueryMap = true && this.isSetHavingFilterSubQueryMap();
    boolean that_present_havingFilterSubQueryMap = true && that.isSetHavingFilterSubQueryMap();
    if (this_present_havingFilterSubQueryMap || that_present_havingFilterSubQueryMap) {
      if (!(this_present_havingFilterSubQueryMap && that_present_havingFilterSubQueryMap))
        return false;
      if (!this.havingFilterSubQueryMap.equals(that.havingFilterSubQueryMap))
        return false;
    }

    boolean this_present_pinotQuery = true && this.isSetPinotQuery();
    boolean that_present_pinotQuery = true && that.isSetPinotQuery();
    if (this_present_pinotQuery || that_present_pinotQuery) {
      if (!(this_present_pinotQuery && that_present_pinotQuery))
        return false;
      if (!this.pinotQuery.equals(that.pinotQuery))
        return false;
    }

    boolean this_present_orderBy = true && this.isSetOrderBy();
    boolean that_present_orderBy = true && that.isSetOrderBy();
    if (this_present_orderBy || that_present_orderBy) {
      if (!(this_present_orderBy && that_present_orderBy))
        return false;
      if (!this.orderBy.equals(that.orderBy))
        return false;
    }

    boolean this_present_limit = true && this.isSetLimit();
    boolean that_present_limit = true && that.isSetLimit();
    if (this_present_limit || that_present_limit) {
      if (!(this_present_limit && that_present_limit))
        return false;
      if (this.limit != that.limit)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int hashCode = 1;

    hashCode = hashCode * 8191 + ((isSetQueryType()) ? 131071 : 524287);
    if (isSetQueryType())
      hashCode = hashCode * 8191 + queryType.hashCode();

    hashCode = hashCode * 8191 + ((isSetQuerySource()) ? 131071 : 524287);
    if (isSetQuerySource())
      hashCode = hashCode * 8191 + querySource.hashCode();

    hashCode = hashCode * 8191 + ((isSetTimeInterval()) ? 131071 : 524287);
    if (isSetTimeInterval())
      hashCode = hashCode * 8191 + timeInterval.hashCode();

    hashCode = hashCode * 8191 + ((isSetDuration()) ? 131071 : 524287);
    if (isSetDuration())
      hashCode = hashCode * 8191 + duration.hashCode();

    hashCode = hashCode * 8191 + ((isSetFilterQuery()) ? 131071 : 524287);
    if (isSetFilterQuery())
      hashCode = hashCode * 8191 + filterQuery.hashCode();

    hashCode = hashCode * 8191 + ((isSetAggregationsInfo()) ? 131071 : 524287);
    if (isSetAggregationsInfo())
      hashCode = hashCode * 8191 + aggregationsInfo.hashCode();

    hashCode = hashCode * 8191 + ((isSetGroupBy()) ? 131071 : 524287);
    if (isSetGroupBy())
      hashCode = hashCode * 8191 + groupBy.hashCode();

    hashCode = hashCode * 8191 + ((isSetSelections()) ? 131071 : 524287);
    if (isSetSelections())
      hashCode = hashCode * 8191 + selections.hashCode();

    hashCode = hashCode * 8191 + ((isSetFilterSubQueryMap()) ? 131071 : 524287);
    if (isSetFilterSubQueryMap())
      hashCode = hashCode * 8191 + filterSubQueryMap.hashCode();

    hashCode = hashCode * 8191 + ((isSetBucketHashKey()) ? 131071 : 524287);
    if (isSetBucketHashKey())
      hashCode = hashCode * 8191 + bucketHashKey.hashCode();

    hashCode = hashCode * 8191 + ((isSetEnableTrace()) ? 131071 : 524287);
    if (isSetEnableTrace())
      hashCode = hashCode * 8191 + ((enableTrace) ? 131071 : 524287);

    hashCode = hashCode * 8191 + ((isSetResponseFormat()) ? 131071 : 524287);
    if (isSetResponseFormat())
      hashCode = hashCode * 8191 + responseFormat.hashCode();

    hashCode = hashCode * 8191 + ((isSetDebugOptions()) ? 131071 : 524287);
    if (isSetDebugOptions())
      hashCode = hashCode * 8191 + debugOptions.hashCode();

    hashCode = hashCode * 8191 + ((isSetQueryOptions()) ? 131071 : 524287);
    if (isSetQueryOptions())
      hashCode = hashCode * 8191 + queryOptions.hashCode();

    hashCode = hashCode * 8191 + ((isSetHavingFilterQuery()) ? 131071 : 524287);
    if (isSetHavingFilterQuery())
      hashCode = hashCode * 8191 + havingFilterQuery.hashCode();

    hashCode = hashCode * 8191 + ((isSetHavingFilterSubQueryMap()) ? 131071 : 524287);
    if (isSetHavingFilterSubQueryMap())
      hashCode = hashCode * 8191 + havingFilterSubQueryMap.hashCode();

    hashCode = hashCode * 8191 + ((isSetPinotQuery()) ? 131071 : 524287);
    if (isSetPinotQuery())
      hashCode = hashCode * 8191 + pinotQuery.hashCode();

    hashCode = hashCode * 8191 + ((isSetOrderBy()) ? 131071 : 524287);
    if (isSetOrderBy())
      hashCode = hashCode * 8191 + orderBy.hashCode();

    hashCode = hashCode * 8191 + ((isSetLimit()) ? 131071 : 524287);
    if (isSetLimit())
      hashCode = hashCode * 8191 + limit;

    return hashCode;
  }

  @Override
  public int compareTo(BrokerRequest other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = java.lang.Boolean.valueOf(isSetQueryType()).compareTo(other.isSetQueryType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQueryType()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryType, other.queryType);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetQuerySource()).compareTo(other.isSetQuerySource());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQuerySource()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.querySource, other.querySource);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetTimeInterval()).compareTo(other.isSetTimeInterval());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetTimeInterval()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timeInterval, other.timeInterval);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetDuration()).compareTo(other.isSetDuration());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDuration()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.duration, other.duration);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetFilterQuery()).compareTo(other.isSetFilterQuery());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFilterQuery()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filterQuery, other.filterQuery);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetAggregationsInfo()).compareTo(other.isSetAggregationsInfo());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetAggregationsInfo()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.aggregationsInfo, other.aggregationsInfo);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetGroupBy()).compareTo(other.isSetGroupBy());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetGroupBy()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.groupBy, other.groupBy);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetSelections()).compareTo(other.isSetSelections());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSelections()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.selections, other.selections);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetFilterSubQueryMap()).compareTo(other.isSetFilterSubQueryMap());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFilterSubQueryMap()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.filterSubQueryMap, other.filterSubQueryMap);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetBucketHashKey()).compareTo(other.isSetBucketHashKey());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetBucketHashKey()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.bucketHashKey, other.bucketHashKey);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetEnableTrace()).compareTo(other.isSetEnableTrace());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEnableTrace()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.enableTrace, other.enableTrace);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetResponseFormat()).compareTo(other.isSetResponseFormat());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetResponseFormat()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.responseFormat, other.responseFormat);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetDebugOptions()).compareTo(other.isSetDebugOptions());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDebugOptions()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.debugOptions, other.debugOptions);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetQueryOptions()).compareTo(other.isSetQueryOptions());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQueryOptions()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryOptions, other.queryOptions);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetHavingFilterQuery()).compareTo(other.isSetHavingFilterQuery());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHavingFilterQuery()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.havingFilterQuery, other.havingFilterQuery);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetHavingFilterSubQueryMap()).compareTo(other.isSetHavingFilterSubQueryMap());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetHavingFilterSubQueryMap()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.havingFilterSubQueryMap, other.havingFilterSubQueryMap);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetPinotQuery()).compareTo(other.isSetPinotQuery());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPinotQuery()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.pinotQuery, other.pinotQuery);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetOrderBy()).compareTo(other.isSetOrderBy());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetOrderBy()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.orderBy, other.orderBy);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = java.lang.Boolean.valueOf(isSetLimit()).compareTo(other.isSetLimit());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLimit()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.limit, other.limit);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  @org.apache.thrift.annotation.Nullable
  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    scheme(iprot).read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    scheme(oprot).write(oprot, this);
  }

  @Override
  public java.lang.String toString() {
    java.lang.StringBuilder sb = new java.lang.StringBuilder("BrokerRequest(");
    boolean first = true;

    if (isSetQueryType()) {
      sb.append("queryType:");
      if (this.queryType == null) {
        sb.append("null");
      } else {
        sb.append(this.queryType);
      }
      first = false;
    }
    if (isSetQuerySource()) {
      if (!first) sb.append(", ");
      sb.append("querySource:");
      if (this.querySource == null) {
        sb.append("null");
      } else {
        sb.append(this.querySource);
      }
      first = false;
    }
    if (isSetTimeInterval()) {
      if (!first) sb.append(", ");
      sb.append("timeInterval:");
      if (this.timeInterval == null) {
        sb.append("null");
      } else {
        sb.append(this.timeInterval);
      }
      first = false;
    }
    if (isSetDuration()) {
      if (!first) sb.append(", ");
      sb.append("duration:");
      if (this.duration == null) {
        sb.append("null");
      } else {
        sb.append(this.duration);
      }
      first = false;
    }
    if (isSetFilterQuery()) {
      if (!first) sb.append(", ");
      sb.append("filterQuery:");
      if (this.filterQuery == null) {
        sb.append("null");
      } else {
        sb.append(this.filterQuery);
      }
      first = false;
    }
    if (isSetAggregationsInfo()) {
      if (!first) sb.append(", ");
      sb.append("aggregationsInfo:");
      if (this.aggregationsInfo == null) {
        sb.append("null");
      } else {
        sb.append(this.aggregationsInfo);
      }
      first = false;
    }
    if (isSetGroupBy()) {
      if (!first) sb.append(", ");
      sb.append("groupBy:");
      if (this.groupBy == null) {
        sb.append("null");
      } else {
        sb.append(this.groupBy);
      }
      first = false;
    }
    if (isSetSelections()) {
      if (!first) sb.append(", ");
      sb.append("selections:");
      if (this.selections == null) {
        sb.append("null");
      } else {
        sb.append(this.selections);
      }
      first = false;
    }
    if (isSetFilterSubQueryMap()) {
      if (!first) sb.append(", ");
      sb.append("filterSubQueryMap:");
      if (this.filterSubQueryMap == null) {
        sb.append("null");
      } else {
        sb.append(this.filterSubQueryMap);
      }
      first = false;
    }
    if (isSetBucketHashKey()) {
      if (!first) sb.append(", ");
      sb.append("bucketHashKey:");
      if (this.bucketHashKey == null) {
        sb.append("null");
      } else {
        sb.append(this.bucketHashKey);
      }
      first = false;
    }
    if (isSetEnableTrace()) {
      if (!first) sb.append(", ");
      sb.append("enableTrace:");
      sb.append(this.enableTrace);
      first = false;
    }
    if (isSetResponseFormat()) {
      if (!first) sb.append(", ");
      sb.append("responseFormat:");
      if (this.responseFormat == null) {
        sb.append("null");
      } else {
        sb.append(this.responseFormat);
      }
      first = false;
    }
    if (isSetDebugOptions()) {
      if (!first) sb.append(", ");
      sb.append("debugOptions:");
      if (this.debugOptions == null) {
        sb.append("null");
      } else {
        sb.append(this.debugOptions);
      }
      first = false;
    }
    if (isSetQueryOptions()) {
      if (!first) sb.append(", ");
      sb.append("queryOptions:");
      if (this.queryOptions == null) {
        sb.append("null");
      } else {
        sb.append(this.queryOptions);
      }
      first = false;
    }
    if (isSetHavingFilterQuery()) {
      if (!first) sb.append(", ");
      sb.append("havingFilterQuery:");
      if (this.havingFilterQuery == null) {
        sb.append("null");
      } else {
        sb.append(this.havingFilterQuery);
      }
      first = false;
    }
    if (isSetHavingFilterSubQueryMap()) {
      if (!first) sb.append(", ");
      sb.append("havingFilterSubQueryMap:");
      if (this.havingFilterSubQueryMap == null) {
        sb.append("null");
      } else {
        sb.append(this.havingFilterSubQueryMap);
      }
      first = false;
    }
    if (isSetPinotQuery()) {
      if (!first) sb.append(", ");
      sb.append("pinotQuery:");
      if (this.pinotQuery == null) {
        sb.append("null");
      } else {
        sb.append(this.pinotQuery);
      }
      first = false;
    }
    if (isSetOrderBy()) {
      if (!first) sb.append(", ");
      sb.append("orderBy:");
      if (this.orderBy == null) {
        sb.append("null");
      } else {
        sb.append(this.orderBy);
      }
      first = false;
    }
    if (isSetLimit()) {
      if (!first) sb.append(", ");
      sb.append("limit:");
      sb.append(this.limit);
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // check for sub-struct validity
    if (queryType != null) {
      queryType.validate();
    }
    if (querySource != null) {
      querySource.validate();
    }
    if (filterQuery != null) {
      filterQuery.validate();
    }
    if (groupBy != null) {
      groupBy.validate();
    }
    if (selections != null) {
      selections.validate();
    }
    if (filterSubQueryMap != null) {
      filterSubQueryMap.validate();
    }
    if (havingFilterQuery != null) {
      havingFilterQuery.validate();
    }
    if (havingFilterSubQueryMap != null) {
      havingFilterSubQueryMap.validate();
    }
    if (pinotQuery != null) {
      pinotQuery.validate();
    }
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class BrokerRequestStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public BrokerRequestStandardScheme getScheme() {
      return new BrokerRequestStandardScheme();
    }
  }

  private static class BrokerRequestStandardScheme extends org.apache.thrift.scheme.StandardScheme<BrokerRequest> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, BrokerRequest struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
          break;
        }
        switch (schemeField.id) {
          case 1: // QUERY_TYPE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.queryType = new QueryType();
              struct.queryType.read(iprot);
              struct.setQueryTypeIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // QUERY_SOURCE
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.querySource = new QuerySource();
              struct.querySource.read(iprot);
              struct.setQuerySourceIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // TIME_INTERVAL
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.timeInterval = iprot.readString();
              struct.setTimeIntervalIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // DURATION
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.duration = iprot.readString();
              struct.setDurationIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // FILTER_QUERY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.filterQuery = new FilterQuery();
              struct.filterQuery.read(iprot);
              struct.setFilterQueryIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 6: // AGGREGATIONS_INFO
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list102 = iprot.readListBegin();
                struct.aggregationsInfo = new java.util.ArrayList<AggregationInfo>(_list102.size);
                @org.apache.thrift.annotation.Nullable AggregationInfo _elem103;
                for (int _i104 = 0; _i104 < _list102.size; ++_i104)
                {
                  _elem103 = new AggregationInfo();
                  _elem103.read(iprot);
                  struct.aggregationsInfo.add(_elem103);
                }
                iprot.readListEnd();
              }
              struct.setAggregationsInfoIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 7: // GROUP_BY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.groupBy = new GroupBy();
              struct.groupBy.read(iprot);
              struct.setGroupByIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 8: // SELECTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.selections = new Selection();
              struct.selections.read(iprot);
              struct.setSelectionsIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 9: // FILTER_SUB_QUERY_MAP
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.filterSubQueryMap = new FilterQueryMap();
              struct.filterSubQueryMap.read(iprot);
              struct.setFilterSubQueryMapIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 10: // BUCKET_HASH_KEY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.bucketHashKey = iprot.readString();
              struct.setBucketHashKeyIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 11: // ENABLE_TRACE
            if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
              struct.enableTrace = iprot.readBool();
              struct.setEnableTraceIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 12: // RESPONSE_FORMAT
            if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
              struct.responseFormat = iprot.readString();
              struct.setResponseFormatIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 13: // DEBUG_OPTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map105 = iprot.readMapBegin();
                struct.debugOptions = new java.util.HashMap<java.lang.String,java.lang.String>(2*_map105.size);
                @org.apache.thrift.annotation.Nullable java.lang.String _key106;
                @org.apache.thrift.annotation.Nullable java.lang.String _val107;
                for (int _i108 = 0; _i108 < _map105.size; ++_i108)
                {
                  _key106 = iprot.readString();
                  _val107 = iprot.readString();
                  struct.debugOptions.put(_key106, _val107);
                }
                iprot.readMapEnd();
              }
              struct.setDebugOptionsIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 14: // QUERY_OPTIONS
            if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
              {
                org.apache.thrift.protocol.TMap _map109 = iprot.readMapBegin();
                struct.queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>(2*_map109.size);
                @org.apache.thrift.annotation.Nullable java.lang.String _key110;
                @org.apache.thrift.annotation.Nullable java.lang.String _val111;
                for (int _i112 = 0; _i112 < _map109.size; ++_i112)
                {
                  _key110 = iprot.readString();
                  _val111 = iprot.readString();
                  struct.queryOptions.put(_key110, _val111);
                }
                iprot.readMapEnd();
              }
              struct.setQueryOptionsIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 15: // HAVING_FILTER_QUERY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.havingFilterQuery = new HavingFilterQuery();
              struct.havingFilterQuery.read(iprot);
              struct.setHavingFilterQueryIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 16: // HAVING_FILTER_SUB_QUERY_MAP
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.havingFilterSubQueryMap = new HavingFilterQueryMap();
              struct.havingFilterSubQueryMap.read(iprot);
              struct.setHavingFilterSubQueryMapIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 17: // PINOT_QUERY
            if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
              struct.pinotQuery = new org.apache.pinot.common.request.PinotQuery();
              struct.pinotQuery.read(iprot);
              struct.setPinotQueryIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 18: // ORDER_BY
            if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
              {
                org.apache.thrift.protocol.TList _list113 = iprot.readListBegin();
                struct.orderBy = new java.util.ArrayList<SelectionSort>(_list113.size);
                @org.apache.thrift.annotation.Nullable SelectionSort _elem114;
                for (int _i115 = 0; _i115 < _list113.size; ++_i115)
                {
                  _elem114 = new SelectionSort();
                  _elem114.read(iprot);
                  struct.orderBy.add(_elem114);
                }
                iprot.readListEnd();
              }
              struct.setOrderByIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 19: // LIMIT
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.limit = iprot.readI32();
              struct.setLimitIsSet(true);
            } else {
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, BrokerRequest struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.queryType != null) {
        if (struct.isSetQueryType()) {
          oprot.writeFieldBegin(QUERY_TYPE_FIELD_DESC);
          struct.queryType.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.querySource != null) {
        if (struct.isSetQuerySource()) {
          oprot.writeFieldBegin(QUERY_SOURCE_FIELD_DESC);
          struct.querySource.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.timeInterval != null) {
        if (struct.isSetTimeInterval()) {
          oprot.writeFieldBegin(TIME_INTERVAL_FIELD_DESC);
          oprot.writeString(struct.timeInterval);
          oprot.writeFieldEnd();
        }
      }
      if (struct.duration != null) {
        if (struct.isSetDuration()) {
          oprot.writeFieldBegin(DURATION_FIELD_DESC);
          oprot.writeString(struct.duration);
          oprot.writeFieldEnd();
        }
      }
      if (struct.filterQuery != null) {
        if (struct.isSetFilterQuery()) {
          oprot.writeFieldBegin(FILTER_QUERY_FIELD_DESC);
          struct.filterQuery.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.aggregationsInfo != null) {
        if (struct.isSetAggregationsInfo()) {
          oprot.writeFieldBegin(AGGREGATIONS_INFO_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.aggregationsInfo.size()));
            for (AggregationInfo _iter116 : struct.aggregationsInfo)
            {
              _iter116.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.groupBy != null) {
        if (struct.isSetGroupBy()) {
          oprot.writeFieldBegin(GROUP_BY_FIELD_DESC);
          struct.groupBy.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.selections != null) {
        if (struct.isSetSelections()) {
          oprot.writeFieldBegin(SELECTIONS_FIELD_DESC);
          struct.selections.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.filterSubQueryMap != null) {
        if (struct.isSetFilterSubQueryMap()) {
          oprot.writeFieldBegin(FILTER_SUB_QUERY_MAP_FIELD_DESC);
          struct.filterSubQueryMap.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.bucketHashKey != null) {
        if (struct.isSetBucketHashKey()) {
          oprot.writeFieldBegin(BUCKET_HASH_KEY_FIELD_DESC);
          oprot.writeString(struct.bucketHashKey);
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetEnableTrace()) {
        oprot.writeFieldBegin(ENABLE_TRACE_FIELD_DESC);
        oprot.writeBool(struct.enableTrace);
        oprot.writeFieldEnd();
      }
      if (struct.responseFormat != null) {
        if (struct.isSetResponseFormat()) {
          oprot.writeFieldBegin(RESPONSE_FORMAT_FIELD_DESC);
          oprot.writeString(struct.responseFormat);
          oprot.writeFieldEnd();
        }
      }
      if (struct.debugOptions != null) {
        if (struct.isSetDebugOptions()) {
          oprot.writeFieldBegin(DEBUG_OPTIONS_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.debugOptions.size()));
            for (java.util.Map.Entry<java.lang.String, java.lang.String> _iter117 : struct.debugOptions.entrySet())
            {
              oprot.writeString(_iter117.getKey());
              oprot.writeString(_iter117.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.queryOptions != null) {
        if (struct.isSetQueryOptions()) {
          oprot.writeFieldBegin(QUERY_OPTIONS_FIELD_DESC);
          {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.queryOptions.size()));
            for (java.util.Map.Entry<java.lang.String, java.lang.String> _iter118 : struct.queryOptions.entrySet())
            {
              oprot.writeString(_iter118.getKey());
              oprot.writeString(_iter118.getValue());
            }
            oprot.writeMapEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.havingFilterQuery != null) {
        if (struct.isSetHavingFilterQuery()) {
          oprot.writeFieldBegin(HAVING_FILTER_QUERY_FIELD_DESC);
          struct.havingFilterQuery.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.havingFilterSubQueryMap != null) {
        if (struct.isSetHavingFilterSubQueryMap()) {
          oprot.writeFieldBegin(HAVING_FILTER_SUB_QUERY_MAP_FIELD_DESC);
          struct.havingFilterSubQueryMap.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.pinotQuery != null) {
        if (struct.isSetPinotQuery()) {
          oprot.writeFieldBegin(PINOT_QUERY_FIELD_DESC);
          struct.pinotQuery.write(oprot);
          oprot.writeFieldEnd();
        }
      }
      if (struct.orderBy != null) {
        if (struct.isSetOrderBy()) {
          oprot.writeFieldBegin(ORDER_BY_FIELD_DESC);
          {
            oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.orderBy.size()));
            for (SelectionSort _iter119 : struct.orderBy)
            {
              _iter119.write(oprot);
            }
            oprot.writeListEnd();
          }
          oprot.writeFieldEnd();
        }
      }
      if (struct.isSetLimit()) {
        oprot.writeFieldBegin(LIMIT_FIELD_DESC);
        oprot.writeI32(struct.limit);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }
  }

  private static class BrokerRequestTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory {
    public BrokerRequestTupleScheme getScheme() {
      return new BrokerRequestTupleScheme();
    }
  }

  private static class BrokerRequestTupleScheme extends org.apache.thrift.scheme.TupleScheme<BrokerRequest> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, BrokerRequest struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet optionals = new java.util.BitSet();
      if (struct.isSetQueryType()) {
        optionals.set(0);
      }
      if (struct.isSetQuerySource()) {
        optionals.set(1);
      }
      if (struct.isSetTimeInterval()) {
        optionals.set(2);
      }
      if (struct.isSetDuration()) {
        optionals.set(3);
      }
      if (struct.isSetFilterQuery()) {
        optionals.set(4);
      }
      if (struct.isSetAggregationsInfo()) {
        optionals.set(5);
      }
      if (struct.isSetGroupBy()) {
        optionals.set(6);
      }
      if (struct.isSetSelections()) {
        optionals.set(7);
      }
      if (struct.isSetFilterSubQueryMap()) {
        optionals.set(8);
      }
      if (struct.isSetBucketHashKey()) {
        optionals.set(9);
      }
      if (struct.isSetEnableTrace()) {
        optionals.set(10);
      }
      if (struct.isSetResponseFormat()) {
        optionals.set(11);
      }
      if (struct.isSetDebugOptions()) {
        optionals.set(12);
      }
      if (struct.isSetQueryOptions()) {
        optionals.set(13);
      }
      if (struct.isSetHavingFilterQuery()) {
        optionals.set(14);
      }
      if (struct.isSetHavingFilterSubQueryMap()) {
        optionals.set(15);
      }
      if (struct.isSetPinotQuery()) {
        optionals.set(16);
      }
      if (struct.isSetOrderBy()) {
        optionals.set(17);
      }
      if (struct.isSetLimit()) {
        optionals.set(18);
      }
      oprot.writeBitSet(optionals, 19);
      if (struct.isSetQueryType()) {
        struct.queryType.write(oprot);
      }
      if (struct.isSetQuerySource()) {
        struct.querySource.write(oprot);
      }
      if (struct.isSetTimeInterval()) {
        oprot.writeString(struct.timeInterval);
      }
      if (struct.isSetDuration()) {
        oprot.writeString(struct.duration);
      }
      if (struct.isSetFilterQuery()) {
        struct.filterQuery.write(oprot);
      }
      if (struct.isSetAggregationsInfo()) {
        {
          oprot.writeI32(struct.aggregationsInfo.size());
          for (AggregationInfo _iter120 : struct.aggregationsInfo)
          {
            _iter120.write(oprot);
          }
        }
      }
      if (struct.isSetGroupBy()) {
        struct.groupBy.write(oprot);
      }
      if (struct.isSetSelections()) {
        struct.selections.write(oprot);
      }
      if (struct.isSetFilterSubQueryMap()) {
        struct.filterSubQueryMap.write(oprot);
      }
      if (struct.isSetBucketHashKey()) {
        oprot.writeString(struct.bucketHashKey);
      }
      if (struct.isSetEnableTrace()) {
        oprot.writeBool(struct.enableTrace);
      }
      if (struct.isSetResponseFormat()) {
        oprot.writeString(struct.responseFormat);
      }
      if (struct.isSetDebugOptions()) {
        {
          oprot.writeI32(struct.debugOptions.size());
          for (java.util.Map.Entry<java.lang.String, java.lang.String> _iter121 : struct.debugOptions.entrySet())
          {
            oprot.writeString(_iter121.getKey());
            oprot.writeString(_iter121.getValue());
          }
        }
      }
      if (struct.isSetQueryOptions()) {
        {
          oprot.writeI32(struct.queryOptions.size());
          for (java.util.Map.Entry<java.lang.String, java.lang.String> _iter122 : struct.queryOptions.entrySet())
          {
            oprot.writeString(_iter122.getKey());
            oprot.writeString(_iter122.getValue());
          }
        }
      }
      if (struct.isSetHavingFilterQuery()) {
        struct.havingFilterQuery.write(oprot);
      }
      if (struct.isSetHavingFilterSubQueryMap()) {
        struct.havingFilterSubQueryMap.write(oprot);
      }
      if (struct.isSetPinotQuery()) {
        struct.pinotQuery.write(oprot);
      }
      if (struct.isSetOrderBy()) {
        {
          oprot.writeI32(struct.orderBy.size());
          for (SelectionSort _iter123 : struct.orderBy)
          {
            _iter123.write(oprot);
          }
        }
      }
      if (struct.isSetLimit()) {
        oprot.writeI32(struct.limit);
      }
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, BrokerRequest struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot;
      java.util.BitSet incoming = iprot.readBitSet(19);
      if (incoming.get(0)) {
        struct.queryType = new QueryType();
        struct.queryType.read(iprot);
        struct.setQueryTypeIsSet(true);
      }
      if (incoming.get(1)) {
        struct.querySource = new QuerySource();
        struct.querySource.read(iprot);
        struct.setQuerySourceIsSet(true);
      }
      if (incoming.get(2)) {
        struct.timeInterval = iprot.readString();
        struct.setTimeIntervalIsSet(true);
      }
      if (incoming.get(3)) {
        struct.duration = iprot.readString();
        struct.setDurationIsSet(true);
      }
      if (incoming.get(4)) {
        struct.filterQuery = new FilterQuery();
        struct.filterQuery.read(iprot);
        struct.setFilterQueryIsSet(true);
      }
      if (incoming.get(5)) {
        {
          org.apache.thrift.protocol.TList _list124 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.aggregationsInfo = new java.util.ArrayList<AggregationInfo>(_list124.size);
          @org.apache.thrift.annotation.Nullable AggregationInfo _elem125;
          for (int _i126 = 0; _i126 < _list124.size; ++_i126)
          {
            _elem125 = new AggregationInfo();
            _elem125.read(iprot);
            struct.aggregationsInfo.add(_elem125);
          }
        }
        struct.setAggregationsInfoIsSet(true);
      }
      if (incoming.get(6)) {
        struct.groupBy = new GroupBy();
        struct.groupBy.read(iprot);
        struct.setGroupByIsSet(true);
      }
      if (incoming.get(7)) {
        struct.selections = new Selection();
        struct.selections.read(iprot);
        struct.setSelectionsIsSet(true);
      }
      if (incoming.get(8)) {
        struct.filterSubQueryMap = new FilterQueryMap();
        struct.filterSubQueryMap.read(iprot);
        struct.setFilterSubQueryMapIsSet(true);
      }
      if (incoming.get(9)) {
        struct.bucketHashKey = iprot.readString();
        struct.setBucketHashKeyIsSet(true);
      }
      if (incoming.get(10)) {
        struct.enableTrace = iprot.readBool();
        struct.setEnableTraceIsSet(true);
      }
      if (incoming.get(11)) {
        struct.responseFormat = iprot.readString();
        struct.setResponseFormatIsSet(true);
      }
      if (incoming.get(12)) {
        {
          org.apache.thrift.protocol.TMap _map127 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
          struct.debugOptions = new java.util.HashMap<java.lang.String,java.lang.String>(2*_map127.size);
          @org.apache.thrift.annotation.Nullable java.lang.String _key128;
          @org.apache.thrift.annotation.Nullable java.lang.String _val129;
          for (int _i130 = 0; _i130 < _map127.size; ++_i130)
          {
            _key128 = iprot.readString();
            _val129 = iprot.readString();
            struct.debugOptions.put(_key128, _val129);
          }
        }
        struct.setDebugOptionsIsSet(true);
      }
      if (incoming.get(13)) {
        {
          org.apache.thrift.protocol.TMap _map131 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
          struct.queryOptions = new java.util.HashMap<java.lang.String,java.lang.String>(2*_map131.size);
          @org.apache.thrift.annotation.Nullable java.lang.String _key132;
          @org.apache.thrift.annotation.Nullable java.lang.String _val133;
          for (int _i134 = 0; _i134 < _map131.size; ++_i134)
          {
            _key132 = iprot.readString();
            _val133 = iprot.readString();
            struct.queryOptions.put(_key132, _val133);
          }
        }
        struct.setQueryOptionsIsSet(true);
      }
      if (incoming.get(14)) {
        struct.havingFilterQuery = new HavingFilterQuery();
        struct.havingFilterQuery.read(iprot);
        struct.setHavingFilterQueryIsSet(true);
      }
      if (incoming.get(15)) {
        struct.havingFilterSubQueryMap = new HavingFilterQueryMap();
        struct.havingFilterSubQueryMap.read(iprot);
        struct.setHavingFilterSubQueryMapIsSet(true);
      }
      if (incoming.get(16)) {
        struct.pinotQuery = new org.apache.pinot.common.request.PinotQuery();
        struct.pinotQuery.read(iprot);
        struct.setPinotQueryIsSet(true);
      }
      if (incoming.get(17)) {
        {
          org.apache.thrift.protocol.TList _list135 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
          struct.orderBy = new java.util.ArrayList<SelectionSort>(_list135.size);
          @org.apache.thrift.annotation.Nullable SelectionSort _elem136;
          for (int _i137 = 0; _i137 < _list135.size; ++_i137)
          {
            _elem136 = new SelectionSort();
            _elem136.read(iprot);
            struct.orderBy.add(_elem136);
          }
        }
        struct.setOrderByIsSet(true);
      }
      if (incoming.get(18)) {
        struct.limit = iprot.readI32();
        struct.setLimitIsSet(true);
      }
    }
  }

  private static <S extends org.apache.thrift.scheme.IScheme> S scheme(org.apache.thrift.protocol.TProtocol proto) {
    return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme();
  }
}
